import {ProductApi} from '@/api'
import globalAxios from "axios";

class ProductService {
    private axiosInstance = globalAxios;
    private productApi = new ProductApi(undefined, import.meta.env.VITE_API_URL, this.axiosInstance);

    getProductInfo() {
        return this.productApi.getProductInfo().then((response) => {
                return response; //List<ProductRO>
            }).catch((error) => {
                console.error("Error fetching product info", error);
                throw error;
            });
    }

    getProductDetail(id: string) {
        return this.productApi.getProductInfoById(id).then((response) => {
            return response; //ProductRO
        }).catch((error) => {
            console.error("Error fetching product detail", error);
            throw error;
        })
    }
}

export const productService = new ProductService()

